package com.pb.wkflow.core.utils;

import com.pb.wkflow.api.exception.ApprovalException;

import java.util.List;

/**
 * @author 苗益辉
 * @date 2022/4/13 9:36
 */
public class AssertUtils {

    private AssertUtils() {

    }

    public static void notTrue(boolean expression, String message){
        if(!expression) {
            throw new ApprovalException(message);
        }
    }

    public static void notFalse(boolean expression, String message){
        if(expression) {
            throw new ApprovalException(message);
        }
    }

    public static void notNull(Object o, String message) {
        if(null == o) {
            throw new ApprovalException(message);
        }
    }

    public static void notEmpty(String str, String message) {
        if(StringUtils.isBlank(str)) {
            throw new ApprovalException(message);
        }
    }

    public static <T> void notEmpty(List<T> list, String message) {
        if(ArrayUtils.isEmpty(list)) {
            throw new ApprovalException(message);
        }
    }
}
